package br.edu.ufcg.greengrid.workload;

import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import com.mallardsoft.tuple.Tuple;

public class BulkDataImpl<E extends Tuple<? extends Comparable<?>, ? extends Comparable<?>>> implements BulkData<E> {

	protected Set<E> entries;

// BUG:	
//	public BulkDataImpl(){
//		this(new Comparator<E>() {
//
//			@Override
//			public int compare(E o1, E o2) {
//				return o1.compareTo(o2);
//			}
//		});
//	}
//	
	
	public BulkDataImpl(Comparator<E> comparator){
		this.entries = new TreeSet<E>(comparator);
	}
	
	@Override
	public List<String> getLines() {
		List<String> lines = new LinkedList<String>();
		for (E e : this.entries) {
			String line = e.toString("", "\t", "");
			lines.add(line);
		}

		return lines;
	}

	public void add(E e){
		this.entries.add(e);
	}
	
}
